package com.ptszyxx.popose.module.main.user.provider;

import androidx.annotation.NonNull;

import com.github.gzuliyujiang.wheelpicker.contract.LinkageProvider;
import com.ysg.http.data.entity.user.AreaEntity;
import com.ysg.http.data.entity.user.CityEntity;
import com.ysg.http.data.entity.user.ProvinceEntity;
import com.ysg.http.data.entity.user.UserAddressResult;

import java.util.ArrayList;
import java.util.List;

public class UserAddressProvider implements LinkageProvider {
    private UserAddressResult addressResult;
    public UserAddressProvider(UserAddressResult addressResult) {
        this.addressResult = addressResult;
    }

    @Override
    public boolean firstLevelVisible() {
        return true;
    }

    @Override
    public boolean thirdLevelVisible() {
        return true;
    }

    @NonNull
    @Override
    public List<String> provideFirstData() {
        List<String> firstList = new ArrayList<>();
        for (ProvinceEntity item: addressResult.getList()) {
            firstList.add(item.getProvince());
        }
        return firstList;
    }

    @NonNull
    @Override
    public List<String> linkageSecondData(int firstIndex) {
        List<String> secondList = new ArrayList<>();
        ProvinceEntity provinceEntity = addressResult.getList().get(firstIndex);
        for (CityEntity item: provinceEntity.getCitiesList()) {
            secondList.add(item.getCity());
        }
        return secondList;
    }

    @NonNull
    @Override
    public List<?> linkageThirdData(int firstIndex, int secondIndex) {
        List<String> thirdList = new ArrayList<>();
        ProvinceEntity provinceEntity = addressResult.getList().get(firstIndex);
        List<CityEntity> citiesList = provinceEntity.getCitiesList();
        CityEntity cityEntity = citiesList.get(secondIndex);
        for (AreaEntity item: cityEntity.getAreaList()) {
            thirdList.add(item.getName());
        }
        return thirdList;
    }

    @Override
    public int findFirstIndex(Object firstValue) {
        return 0;
    }

    @Override
    public int findSecondIndex(int firstIndex, Object secondValue) {
        return 0;
    }

    @Override
    public int findThirdIndex(int firstIndex, int secondIndex, Object thirdValue) {
        return 0;
    }
}
